/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Chien
 */
@Entity
@Table(name = "TBL_CONTACT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Contact.findAll", query = "SELECT c FROM Contact c"),
    @NamedQuery(name = "Contact.findByContactId", query = "SELECT c FROM Contact c WHERE c.contactId = :contactId"),
    @NamedQuery(name = "Contact.findByTitle", query = "SELECT c FROM Contact c WHERE c.title = :title"),
    @NamedQuery(name = "Contact.findByContentContact", query = "SELECT c FROM Contact c WHERE c.contentContact = :contentContact"),
    @NamedQuery(name = "Contact.findByContactDate", query = "SELECT c FROM Contact c WHERE c.contactDate = :contactDate"),
    @NamedQuery(name = "Contact.findByIsAccepted", query = "SELECT c FROM Contact c WHERE c.isAccepted = :isAccepted")})
public class Contact implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "ContactId")
    private String contactId;
    @Size(max = 250)
    @Column(name = "Title")
    private String title;
    @Size(max = 2000)
    @Column(name = "ContentContact")
    private String contentContact;
    @Column(name = "ContactDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date contactDate;
    @Column(name = "IsAccepted")
    private Boolean isAccepted;
    @JoinColumn(name = "UserId", referencedColumnName = "UserName")
    @ManyToOne
    private User userId;

    public Contact() {
    }

    public Contact(String contactId) {
        this.contactId = contactId;
    }

    public String getContactId() {
        return contactId;
    }

    public void setContactId(String contactId) {
        this.contactId = contactId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContentContact() {
        return contentContact;
    }

    public void setContentContact(String contentContact) {
        this.contentContact = contentContact;
    }

    public Date getContactDate() {
        return contactDate;
    }

    public void setContactDate(Date contactDate) {
        this.contactDate = contactDate;
    }

    public Boolean getIsAccepted() {
        return isAccepted;
    }

    public void setIsAccepted(Boolean isAccepted) {
        this.isAccepted = isAccepted;
    }

    public User getUserId() {
        return userId;
    }

    public void setUserId(User userId) {
        this.userId = userId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (contactId != null ? contactId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Contact)) {
            return false;
        }
        Contact other = (Contact) object;
        if ((this.contactId == null && other.contactId != null) || (this.contactId != null && !this.contactId.equals(other.contactId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Contact[ contactId=" + contactId + " ]";
    }
    
}
